package org.givwenzen.nature;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.givwenzen.builder.GivWenZenNature;

public class GivWenZenNatureDetector {

    public IProject detectProject() {
        IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
        for (IProject p : projects) {
            try {
                if (p.hasNature(GivWenZenNature.NATURE_ID)) {
                    return p;
                }
            } catch (CoreException e) {
                throw new RuntimeException("GivWenZenPlugin has problems detecting the nature of projects", e);
            }
        }
        return null;
    }
}
